#pragma once

#include <list>
#include <map>
using std::multimap;
using std::pair;
using std::list;

#include "CEvent.h"
#include "IListener.h"

class CSGP_EventSystem
{
private:
	// Map of clients that are listening for events
	multimap<eventID, IListener*>	m_ListenerDatabase;

	// Events to be processed
	list<CEvent>	m_CurrEvents;

	void DispatchEvent(CEvent* pEvent);
	
	CSGP_EventSystem() {} 
	CSGP_EventSystem(const CSGP_EventSystem&);
	CSGP_EventSystem& operator=(const CSGP_EventSystem&);

	~CSGP_EventSystem() {}

public:

	static CSGP_EventSystem* GetInstance(void)
	{
		static CSGP_EventSystem inst;
		return &inst;
	}

	// Add listener classes
	void RegisterClient(eventID evID, IListener* pClient);

	// Unregister listener classes
	void UnregisterClient(eventID evID, IListener* pClient);

	// Send an event to a listener
	void SendEvent(eventID evID, void* pData = NULL);

	// Process events
	void ProcessEvents(void);

	// Clear events from the list
	void ClearEvents(void);

	// Shutdown the event system
	void ShutdownEventSystem(void);
};